package com.me.myapplication;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.MenuItem;
import android.widget.TextView;

public class ShowResultActivity extends AppCompatActivity {

    TextView showData;
    TextView countInfo;
    Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_result);
        showData = findViewById(R.id.tv_show_result);
        countInfo = findViewById(R.id.tv_count_info);
        toolbar = findViewById(R.id.toolbar);

        showData.setMovementMethod(new ScrollingMovementMethod());
        countInfo.setMovementMethod(new ScrollingMovementMethod());

        showData.setTextIsSelectable(true);

        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        if(actionBar != null){
            actionBar.setTitle("POI数据");
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        Intent intent = getIntent();
        if(null != intent){
            String data = intent.getStringExtra("Data");
            String countInfoStr = intent.getStringExtra("Count");
            showData.setText(data);
            countInfo.setText(countInfoStr);
        }
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()){
            case android.R.id.home:
                finish();
                break;
                default:
        }
        return super.onOptionsItemSelected(item);
    }
}
